/*
 * @Description:
 * @Author: qingyang
 * @Date: 2023-02-27 09:50:22
 * @LastEditors: qingyang
 * @LastEditTime: 2023-03-06 15:32:10
 */
import type { IFactorType } from '@/apis/eci/discharge/model/dischargeFillModel'
import type { BasicPagingListParams } from '@/apis/basicModel'
import {
  CorrectionGradeEnum,
  DataOriginEnum,
  EmissionCategoryEnum,
  EmissionScopeEnum,
  FillInTaskStatusEnum,
  FillInTaskIssueStatusEnum,
  InventoryStatusEnum
} from '@/constants/enum'
import type { IAccountStage } from '@/apis/eci/discharge/model/dischargeFillModel'
// 碳排放监测计划分页查询接口 入参
export interface GetInventoryParams extends BasicPagingListParams {
  /**
   * 适用年份
   */
  applicableYear?: string
  /**
   * 组织编码
   */
  organizationCode?: string
  /**
   * 发布状态
   */
  status: keyof typeof InventoryStatusEnum
  /**
   * 起始时间
   */
  startTime?: string
  /**
   * 结束时间
   */
  endTime?: string
}

// 碳排放监测计划分页查询接口 返回参数
export interface GetInventoryResult {
  // 监测计划编号
  inventoryNo: string
  // 监测计划名称
  inventoryName: string
  /**
   * 组织编号
   */
  organizationCode: string
  /**
   * 组织名称
   */
  organizationName: string
  /**
   * 创建时间
   */
  createTime: string
  /**
   * 更新时间
   */
  updateTime: string
  /**
   * 发布时间
   */
  releaseTime: string
  // 状态
  status: keyof typeof InventoryStatusEnum
  /**
   * 使用年份
   */
  applicableYear: string
}

// 备注信息保存接口 入参
export interface InventoryNotesSaveParams {
  // 监测计划编号
  inventoryNo: string
  // 备注
  notes: string
}

// 监测计划option列表 返回参数
export interface GetInventoryOptionListResult {
  // 监测计划编号
  inventoryNo: string
  // 监测计划名称
  inventoryName: string
  // 组织code
  organizationCode: string
  // 组织名称
  organizationName: string
  // 企业名称
  companyName: string
  // 排放类别
  emissionCategory: string
  // 排放范围
  emissionScope: string
}

export interface IBaseInfoParams {
  inventoryNo?: string
  organizationCode: string
  boundary: string
  applicableYear: string
  planarGraphName: string
  planarGraphUrl: string
  fillFrequency: string
  auditorId: string
  auditor: string
  auditorEmail: string
}

export interface IBaseInfo extends Omit<IBaseInfoDetail, 'planarGraphUrl' | 'planarGraphName'> {
  orgFileList: any[]
  planarFileList: any[]
  auditorOptions: any[]
}

export interface IBaseInfoDetail extends GetInventoryResult {
  boundary: string // 核算边界
  planarGraphName: string
  planarGraphUrl: string
  companyName: string
  companyAddress: string
  contact: string
  contactEmail: string
  contactPhone: string
  fillFrequency: string
  auditorId: string
  auditor: string
  auditorEmail: string
  /**
   * 审核人是否存在
   * 不存在说明用户账号被删除了，需要重新选择审核人
   */
  auditorExist: boolean
}

export interface IFacilityResult {
  inventoryNo: string
  inventoryFacilityNo: string
  emissionScope: keyof typeof EmissionScopeEnum
  emissionCategory: keyof typeof EmissionCategoryEnum
  ghgSourceType: string
  sourceNo: string
  sourceName: string
  materialNo: string
  materialName: string
  facilityModel: string
  facilityLocation: string
  dataUnit: string
  dataOrigin: keyof typeof DataOriginEnum
  chargeDepartment: string
  correctionGrade: keyof typeof CorrectionGradeEnum
  mixedGasList: {
    gas: string
    ratio: string
    molarMass: string
  }[]
  emsDeviceIds: string[]
  abandonedFlag: boolean
  refreshFlag: boolean
}

export interface ISourceFactorParams {
  catalogNo: string
  type: IFactorType
  name?: string
}

export interface IFacilitySaveParams {
  inventoryNo: string
  inventoryFacilityNo?: string
  facilityName: string
  facilityNo: string
  facilityModel: string
  facilityLocation: string
  frameworkInfoList: string[]
  sourceNo: string
  sourceName: string
  materialNo: string
  materialName: string
  emsDeviceIds?: string[]
  emsMeterType?: string
}

interface IFileItem {
  attachmentName: string
  attachmentUrl: string
}
export interface IFacilitySourceSaveParams {
  inventoryNo: string
  inventoryFacilityNo: string
  sourceNo?: string
  dataDesc: string
  dataAccessMethod: string
  dataUnit: string
  dataSourceFile: IFileItem[]
  dataFrequency: string | number
  dataFrequencyUnit: string
  dataAccessDepartment: string
  testEquipmentName: string
  testEquipmentModel: string
  testEquipmentLocation: string
  testEquipmentFrequencyDesc: string
  dataStreamDesc: string
  dataMissProcessDesc: string
  accuracy: string
}

export interface IFacilitySourceDetail extends IFacilitySourceSaveParams {
  sourceName: string
  catalogInfo: string[]
  catalogDesc: string
  materialName: string
  frameworkType: IAccountStage
}
export interface IFacilityDetail extends IFacilityResult {
  inventoryFacilityNo: string
  facilityName: string
  facilityNo: string
  catalogDesc: string
  emsMeterType: string
  catalogInfo: string[]
}

export interface IFacilityDetailParams {
  inventoryNo: string
  inventoryFacilityNo: string
}

export interface IFacilityCountRes {
  sourceCount: number
  sourceCompletedCount: number
  emissionScopeOneCount: number
  emissionScopeTwoCount: number
  emissionScopeThreeCount: number
}

export interface IEmsDevice {
  dataUnitGroup: string
  deviceNo: string
  id: number
  meterId: string
  meterName: string
  meterType: string
  plantId: string
  plantName: string
}

export interface IInventoryOptionsParams {
  organizationCode: string
  year: string
}

/**
 * 查询监测计划对应的填报任务 返回参数
 */
export interface GetListFillTaskResult {
  taskNo: string
  taskName: string
  /**
   * 任务状态
   */
  taskStatus: keyof typeof FillInTaskStatusEnum
  /**
   * 任务下发状态
   */
  taskIssueStatus: keyof typeof FillInTaskIssueStatusEnum
  /**
   * 填报周期
   */
  fillPeriod: string
  /**
   * 实际下发时间
   */
  taskIssueTime: string
  /**
   * 预计下发时间
   */
  expectIssueTime: string
}
